cmake_minimum_required(VERSION 2.8)
project(cstack_gm)

# 设置生成库的名称
set(LIB_NAME ${CMAKE_PROJECT_NAME})
# 设置项目根路径
set(PROJECT_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
#-------------------------------------------------------------------------------
# project setting
#-------------------------------------------------------------------------------
# setting for compiling in debug or release mode
if(${CMAKE_BUILD_TYPE} MATCHES "RELEASE")
  message(STATUS "Release版本")
  set(BuildType "Release")
  # -g表示添加gdb调试选项
  set(CMAKE_CXX_FLAGS_RELEASE "-g -O2 -finline-limit=1000")
  set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
  link_directories()
else()
  message(STATUS "Debug版本")
  set(BuildType "Debug")
  add_definitions(-DDEBUG)
# 指定Debug模式下编译选项，CMAKE_CXX_FLAGS_DEBUG为cmake内置变量
  set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
  set(CMAKE_CXX_FLAGS "-g -O0 ${CMAKE_CXX_FLAGS}")
endif()

#设置lib库目录
set(LIB_DIR ${PROJECT_ROOT_DIR}/lib)
# debug和release版本目录不一样
#设置生成的so动态库最后输出的路径
link_directories(${LIB_DIR}/${BuildType})
# C++ 编译选项
set(CXX_FLAGS
  -std=c++11
  -Wno-overflow
  -Wno-conversion-null
  -Wno-maybe-uninitialized
  -Wno-uninitialized
  -Wno-sequence-point
  -Wno-write-strings
  -Wno-unused-label
  -Wno-unused-variable
  -Wno-unused-variable
  -Wno-deprecated
  -Wno-unused-but-set-variable -pthread)

include_directories(include)

add_subdirectory(src)
add_subdirectory(test)
